package com.jn.touchdemo.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

import androidx.annotation.Nullable;

public class TouchView extends androidx.appcompat.widget.AppCompatTextView {
   public static final String TAG = "View";
   public TouchView(Context context) {
      super(context);
   }

   public TouchView(Context context, @Nullable AttributeSet attrs) {
      super(context, attrs);
   }

   @SuppressLint("ClickableViewAccessibility")
   @Override
   public boolean onTouchEvent(MotionEvent event) {
      switch (event.getAction()) {
         case MotionEvent.ACTION_DOWN:
            Log.d(TAG, "~~~~~~~onTouchEvent~~~~~~~down");
            break;
         case MotionEvent.ACTION_MOVE:
            Log.d(TAG, "~~~~~~~onTouchEvent~~~~~~~move");
            break;
         case MotionEvent.ACTION_UP:
            Log.d(TAG, "~~~~~~~onTouchEvent~~~~~~~up");
            break;
         case MotionEvent.ACTION_CANCEL:
            Log.d(TAG, "~~~~~~~onTouchEvent~~~~~~~cancel");
            break;
      }
      return super.onTouchEvent(event);
   }

   @Override
   public boolean dispatchTouchEvent(MotionEvent event) {
      switch (event.getAction()) {
         case MotionEvent.ACTION_DOWN:
            Log.d(TAG, "~~~~~~~dispatchTouchEvent~~~~~~~down");
            break;
         case MotionEvent.ACTION_MOVE:
            Log.d(TAG, "~~~~~~~dispatchTouchEvent~~~~~~~move");
            break;
         case MotionEvent.ACTION_UP:
            Log.d(TAG, "~~~~~~~dispatchTouchEvent~~~~~~~up");
            break;
         case MotionEvent.ACTION_CANCEL:
            Log.d(TAG, "~~~~~~~dispatchTouchEvent~~~~~~~cancel");
            break;
      }
      return super.dispatchTouchEvent(event);
   }
}
